package com.chendx.store.behavior.controller;

import com.chendx.model.behivor.dto.UserBehaviorDto;
import com.chendx.model.behivor.pojo.UserFocus;
import com.chendx.model.common.dtos.PageRequestDto;
import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.store.api.behavior.UserBehaviorControllerApi;
import com.chendx.store.behavior.service.UserBehaviorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by chendx on 2022/4/20.
 */
@RestController
@RequestMapping("/api/behavior")
public class UserBehaviorController implements UserBehaviorControllerApi {

    @Autowired
    private UserBehaviorService userBehaviorService;


    @Override
    @PostMapping("/focus")
    public ResponseResult focus(@RequestBody UserBehaviorDto dto) {
        return userBehaviorService.focus(dto);
    }

    @Override
    @GetMapping("/isFocus")
    public ResponseResult isFocus(String skuId) {
        return userBehaviorService.isFocus(skuId);
    }

    @Override
    @PostMapping("/collect")
    public ResponseResult collect(@RequestBody UserBehaviorDto dto) {
        return userBehaviorService.collect(dto);
    }

    @Override
    @GetMapping("/isCollect")
    public ResponseResult isCollect(String spuId) {
        return userBehaviorService.isCollect(spuId);
    }

    @Override
    @GetMapping("/focusCount")
    public ResponseResult focusCount() {
        return userBehaviorService.focusCount();
    }


    @Override
    @GetMapping("/collectCount")
    public ResponseResult collectCount(){
        return userBehaviorService.collectCount();
    }

    @Override
    @GetMapping("/focus4user")
    public List<UserFocus> focusUser(String id) {
        return userBehaviorService.focus4user(id);
    }

    @Override
    @GetMapping("/loadCollect")
    public ResponseResult loadCollection() {
        return userBehaviorService.loadCollection();
    }

    @Override
    @PostMapping("/loadFocus")
    public ResponseResult loadFocus(@RequestBody PageRequestDto dto) {
        return userBehaviorService.loadFocus(dto);
    }


}
